<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: SensorApplLayer Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00191.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="#pri-methods">Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">SensorApplLayer Class Reference<div class="ingroups"><a class="el" href="a00506.html">applLayer - application layer modules</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="SensorApplLayer" --><!-- doxytag: inherits="BaseLayer" -->
<p>Test class for the application layer.  
 <a href="a00191.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00414_source.html">SensorApplLayer.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for SensorApplLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a00992.png" border="0" usemap="#SensorApplLayer_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for SensorApplLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a00993.png" border="0" usemap="#SensorApplLayer_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00994.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>APPL_MSG_TYPES</b> { <b>SEND_DATA_TIMER</b>, 
<b>STOP_SIM_TIMER</b>, 
<b>DATA_MESSAGE</b>
 }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>TRAFFIC_TYPES</b> { <br/>
&#160;&#160;<b>UNKNOWN</b> =  0, 
<b>PERIODIC</b>, 
<b>UNIFORM</b>, 
<b>EXPONENTIAL</b>, 
<br/>
&#160;&#160;<b>NB_DISTRIBUTIONS</b>
<br/>
 }</td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#aac9612746afd57f4393658789d3c64fe">initialize</a> (int)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization of the module and some variables.  <a href="#aac9612746afd57f4393658789d3c64fe"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3dd29a64d1a719cd0eaea713604a4791"></a><!-- doxytag: member="SensorApplLayer::finish" ref="a3dd29a64d1a719cd0eaea713604a4791" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a3dd29a64d1a719cd0eaea713604a4791">finish</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Called when the simulation has finished. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#af822f0d57cf5642efe603f6fd83612c0">handleSelfMsg</a> (cMessage *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle self messages such as timer...  <a href="#af822f0d57cf5642efe603f6fd83612c0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a1100fd46a8ced89ff27dd845de9c0d63">handleLowerMsg</a> (cMessage *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle messages from lower layer.  <a href="#a1100fd46a8ced89ff27dd845de9c0d63"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae7d9070dfdde5b29f9d707973f81099f"></a><!-- doxytag: member="SensorApplLayer::handleLowerControl" ref="ae7d9070dfdde5b29f9d707973f81099f" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#ae7d9070dfdde5b29f9d707973f81099f">handleLowerControl</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle control messages from lower layer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a999fc38567d79965df17646dcbf38e84">handleUpperMsg</a> (cMessage *m)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle messages from upper layer.  <a href="#a999fc38567d79965df17646dcbf38e84"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a92df66edc3522240f26e56c25e5c1c21"></a><!-- doxytag: member="SensorApplLayer::handleUpperControl" ref="a92df66edc3522240f26e56c25e5c1c21" args="(cMessage *m)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a92df66edc3522240f26e56c25e5c1c21">handleUpperControl</a> (cMessage *m)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle control messages from upper layer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a874cfc7ac28f9b46f51eea860536ab59">sendData</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">send a data packet to the next hop  <a href="#a874cfc7ac28f9b46f51eea860536ab59"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a08e69649b4aa1b598216c5aa2d12e940"></a><!-- doxytag: member="SensorApplLayer::initializeDistribution" ref="a08e69649b4aa1b598216c5aa2d12e940" args="(const char *)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a08e69649b4aa1b598216c5aa2d12e940">initializeDistribution</a> (const char *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Recognize distribution name. Redefine this method to add your own distribution. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a246b38e417b96f476d61a5f6899a11b7"></a><!-- doxytag: member="SensorApplLayer::scheduleNextPacket" ref="a246b38e417b96f476d61a5f6899a11b7" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a246b38e417b96f476d61a5f6899a11b7">scheduleNextPacket</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">calculate time to wait before sending next packet, if required. You can redefine this method in a subclass to add your own distribution. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cStdDev &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#ac9d94d2ed83444dbea11b6255f0cd1b0">hostsLatency</a> (const <a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a> &amp;hostAddress)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the latency statistics variable for the passed host address.  <a href="#ac9d94d2ed83444dbea11b6255f0cd1b0"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3375e6f49ac3784496a7a6ffe9e2fc35"></a><!-- doxytag: member="SensorApplLayer::delayTimer" ref="a3375e6f49ac3784496a7a6ffe9e2fc35" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>delayTimer</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a72e00ca1da89eba0b3bcb1605e0c08ee"></a><!-- doxytag: member="SensorApplLayer::myAppAddr" ref="a72e00ca1da89eba0b3bcb1605e0c08ee" args="" -->
<a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a>&#160;</td><td class="memItemRight" valign="bottom"><b>myAppAddr</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9940a24ee62f9cecdbea289ca2e85c87"></a><!-- doxytag: member="SensorApplLayer::destAddr" ref="a9940a24ee62f9cecdbea289ca2e85c87" args="" -->
<a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a>&#160;</td><td class="memItemRight" valign="bottom"><b>destAddr</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acf6112c3199e4da114ac4b1c9cd67eee"></a><!-- doxytag: member="SensorApplLayer::sentPackets" ref="acf6112c3199e4da114ac4b1c9cd67eee" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>sentPackets</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a27d84efacfd12f69d4b8ce46c7d81e3c"></a><!-- doxytag: member="SensorApplLayer::initializationTime" ref="a27d84efacfd12f69d4b8ce46c7d81e3c" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><b>initializationTime</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a638d8d62f6fbf0f83ea7817d08527949"></a><!-- doxytag: member="SensorApplLayer::firstPacketGeneration" ref="a638d8d62f6fbf0f83ea7817d08527949" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><b>firstPacketGeneration</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a39eeaa89f77e3fec16674571263ab353"></a><!-- doxytag: member="SensorApplLayer::lastPacketReception" ref="a39eeaa89f77e3fec16674571263ab353" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><b>lastPacketReception</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7f256e95120539f7e4ec12b9e98fd87e"></a><!-- doxytag: member="SensorApplLayer::trafficType" ref="a7f256e95120539f7e4ec12b9e98fd87e" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>trafficType</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae0e8514e2d8d1390c9504fc2d4dc458e"></a><!-- doxytag: member="SensorApplLayer::trafficParam" ref="ae0e8514e2d8d1390c9504fc2d4dc458e" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>trafficParam</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abd87aa5ce596b1b9d985828be9f89779"></a><!-- doxytag: member="SensorApplLayer::nbPackets" ref="abd87aa5ce596b1b9d985828be9f89779" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>nbPackets</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a67fa481f2752142bf155cdb7010efd41"></a><!-- doxytag: member="SensorApplLayer::nbPacketsSent" ref="a67fa481f2752142bf155cdb7010efd41" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbPacketsSent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a971e61f21143b670e7c4462d5f8d54ab"></a><!-- doxytag: member="SensorApplLayer::nbPacketsReceived" ref="a971e61f21143b670e7c4462d5f8d54ab" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbPacketsReceived</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8c46dd133a8360b2b7ab2a43549cb61f"></a><!-- doxytag: member="SensorApplLayer::stats" ref="a8c46dd133a8360b2b7ab2a43549cb61f" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>stats</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a59083df1439f7a7d3f05f432dc1659b5"></a><!-- doxytag: member="SensorApplLayer::trace" ref="a59083df1439f7a7d3f05f432dc1659b5" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>trace</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6d8bd1aaca78da940546c05fb597bf00"></a><!-- doxytag: member="SensorApplLayer::debug" ref="a6d8bd1aaca78da940546c05fb597bf00" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a6d8bd1aaca78da940546c05fb597bf00">debug</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Debug switch for all other modules. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3decc9ad2daaaadc24e54f612f735dae"></a><!-- doxytag: member="SensorApplLayer::broadcastPackets" ref="a3decc9ad2daaaadc24e54f612f735dae" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>broadcastPackets</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9b01d3a81c84371cac5bd38985a27de7"></a><!-- doxytag: member="SensorApplLayer::latencies" ref="a9b01d3a81c84371cac5bd38985a27de7" args="" -->
std::map&lt; <a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a>, <br class="typebreak"/>
cStdDev &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>latencies</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad56d0d82d8dc0c36ccf7f4958feb381e"></a><!-- doxytag: member="SensorApplLayer::latency" ref="ad56d0d82d8dc0c36ccf7f4958feb381e" args="" -->
cStdDev&#160;</td><td class="memItemRight" valign="bottom"><b>latency</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0f405c2797c0609b7a093449c4da3f5b"></a><!-- doxytag: member="SensorApplLayer::latenciesRaw" ref="a0f405c2797c0609b7a093449c4da3f5b" args="" -->
cOutVector&#160;</td><td class="memItemRight" valign="bottom"><b>latenciesRaw</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a169d60c938ce6ea91954f5085ccc5164"></a><!-- doxytag: member="SensorApplLayer::packet" ref="a169d60c938ce6ea91954f5085ccc5164" args="" -->
<a class="el" href="a00168.html">Packet</a>&#160;</td><td class="memItemRight" valign="bottom"><b>packet</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a61a1450b8823596784f09befffa791f2"></a><!-- doxytag: member="SensorApplLayer::headerLength" ref="a61a1450b8823596784f09befffa791f2" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>headerLength</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a059d142df87f53397e49178fc3bea03f"></a><!-- doxytag: member="SensorApplLayer::world" ref="a059d142df87f53397e49178fc3bea03f" args="" -->
<a class="el" href="a00030.html">BaseWorldUtility</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>world</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a02ce31b9a41fb7dd4ac97f53cfd45671"></a><!-- doxytag: member="SensorApplLayer::dataOut" ref="a02ce31b9a41fb7dd4ac97f53cfd45671" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>dataOut</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a50407433f2187e17eeca411c2e07bf2e"></a><!-- doxytag: member="SensorApplLayer::dataIn" ref="a50407433f2187e17eeca411c2e07bf2e" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>dataIn</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeeb05a8981390520fc56593c5764810f"></a><!-- doxytag: member="SensorApplLayer::ctrlOut" ref="aeeb05a8981390520fc56593c5764810f" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>ctrlOut</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab4862ee2fc1a727b44d07b2d4a5a00ae"></a><!-- doxytag: member="SensorApplLayer::ctrlIn" ref="ab4862ee2fc1a727b44d07b2d4a5a00ae" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>ctrlIn</b></td></tr>
<tr><td colspan="2"><h2><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a39256e730b7fc84e5868809b3625bd11"></a><!-- doxytag: member="SensorApplLayer::SensorApplLayer" ref="a39256e730b7fc84e5868809b3625bd11" args="(const SensorApplLayer &amp;)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a39256e730b7fc84e5868809b3625bd11">SensorApplLayer</a> (const <a class="el" href="a00191.html">SensorApplLayer</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor is not allowed. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1d82e523d2e9cee09568c311e738628c"></a><!-- doxytag: member="SensorApplLayer::operator=" ref="a1d82e523d2e9cee09568c311e738628c" args="(const SensorApplLayer &amp;)" -->
<a class="el" href="a00191.html">SensorApplLayer</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00191.html#a1d82e523d2e9cee09568c311e738628c">operator=</a> (const <a class="el" href="a00191.html">SensorApplLayer</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment operator is not allowed. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Test class for the application layer. </p>
<p>All nodes periodically generate a packet addressed to a sink. This class takes three arguments:</p>
<ul>
<li>packets: the number of packets to be sent by this application.</li>
<li>trafficType: affects how the time interval between two packets is generated. Possible values are "periodic", "uniform", and "exponential".</li>
<li>trafficParam: parameter for traffic type. For "periodic" traffic this value is the constant time interval, for "uniform" traffic this is the maximum time interval between two packets and for "exponential" it is the mean value. These values are expressed in seconds.</li>
</ul>
<dl class="author"><dt><b>Author:</b></dt><dd>Amre El-Hoiydi, Jérôme Rousselot </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a1100fd46a8ced89ff27dd845de9c0d63"></a><!-- doxytag: member="SensorApplLayer::handleLowerMsg" ref="a1100fd46a8ced89ff27dd845de9c0d63" args="(cMessage *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SensorApplLayer::handleLowerMsg </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Handle messages from lower layer. </p>
<p>Handling of messages arrived to destination. </p>

<p>Implements <a class="el" href="a00025.html#a5ca2278405070baa474dfbf059930247">BaseLayer</a>.</p>

<p>References <a class="el" href="a00025.html#a665bf8ad06b2c4b5419669869e68ef00">BaseLayer::catPacketSignal</a>, and <a class="el" href="a00191.html#ac9d94d2ed83444dbea11b6255f0cd1b0">hostsLatency()</a>.</p>
<div class="fragment"><pre class="fragment">                                                   {
  ApplPkt *m;

  <span class="keywordflow">switch</span> (msg-&gt;getKind()) {
  <span class="keywordflow">case</span> DATA_MESSAGE:
    m = <span class="keyword">static_cast&lt;</span>ApplPkt *<span class="keyword">&gt;</span> (msg);
    nbPacketsReceived++;
    packet.setPacketSent(<span class="keyword">false</span>);
    packet.setNbPacketsSent(0);
    packet.setNbPacketsReceived(1);
    packet.setHost(myAppAddr);
    emit(<a class="code" href="a00025.html#a665bf8ad06b2c4b5419669869e68ef00" title="SignalID for packets.">BaseLayer::catPacketSignal</a>, &amp;packet);
    <span class="keywordflow">if</span> (stats) {
      simtime_t theLatency = m-&gt;getArrivalTime() - m-&gt;getCreationTime();
      <span class="keywordflow">if</span>(trace) {
        <a class="code" href="a00191.html#ac9d94d2ed83444dbea11b6255f0cd1b0" title="Returns the latency statistics variable for the passed host address.">hostsLatency</a>(m-&gt;getSrcAddr()).collect(theLatency);
        latenciesRaw.record(SIMTIME_DBL(theLatency));
      }
      latency.collect(theLatency);
      <span class="keywordflow">if</span> (firstPacketGeneration &lt; 0)
        firstPacketGeneration = m-&gt;getCreationTime();
      lastPacketReception = m-&gt;getArrivalTime();
      <span class="keywordflow">if</span>(trace) {
        debugEV&lt;&lt; <span class="stringliteral">&quot;Received a data packet from host[&quot;</span> &lt;&lt; m-&gt;getSrcAddr()
        &lt;&lt; <span class="stringliteral">&quot;], latency=&quot;</span> &lt;&lt; theLatency
        &lt;&lt; <span class="stringliteral">&quot;, collected &quot;</span> &lt;&lt; <a class="code" href="a00191.html#ac9d94d2ed83444dbea11b6255f0cd1b0" title="Returns the latency statistics variable for the passed host address.">hostsLatency</a>(m-&gt;getSrcAddr()).
        getCount() &lt;&lt; <span class="stringliteral">&quot;mean is now: &quot;</span> &lt;&lt; <a class="code" href="a00191.html#ac9d94d2ed83444dbea11b6255f0cd1b0" title="Returns the latency statistics variable for the passed host address.">hostsLatency</a>(m-&gt;getSrcAddr()).
        getMean() &lt;&lt; endl;
      } <span class="keywordflow">else</span> {
          debugEV&lt;&lt; <span class="stringliteral">&quot;Received a data packet from host[&quot;</span> &lt;&lt; m-&gt;getSrcAddr()
          &lt;&lt; <span class="stringliteral">&quot;], latency=&quot;</span> &lt;&lt; theLatency &lt;&lt; endl;
      }
    }
    <span class="keyword">delete</span> msg;

    <span class="comment">//  sendReply(m);</span>
    <span class="keywordflow">break</span>;
    <span class="keywordflow">default</span>:
    EV &lt;&lt; <span class="stringliteral">&quot;Error! got packet with unknown kind: &quot;</span> &lt;&lt; msg-&gt;getKind() &lt;&lt; endl;
    <span class="keyword">delete</span> msg;
    <span class="keywordflow">break</span>;
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="af822f0d57cf5642efe603f6fd83612c0"></a><!-- doxytag: member="SensorApplLayer::handleSelfMsg" ref="af822f0d57cf5642efe603f6fd83612c0" args="(cMessage *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SensorApplLayer::handleSelfMsg </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Handle self messages such as timer... </p>
<p>A timer with kind = SEND_DATA_TIMER indicates that a new data has to be send (<a class="el" href="a00191.html#a874cfc7ac28f9b46f51eea860536ab59">sendData</a>).</p>
<p>There are no other timers implemented for this module.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00191.html#a874cfc7ac28f9b46f51eea860536ab59" title="send a data packet to the next hop">sendData</a> </dd></dl>

<p>Implements <a class="el" href="a00025.html#a87d7e1e5aa73216f07e35d7be4358924">BaseLayer</a>.</p>

<p>References <a class="el" href="a00191.html#a874cfc7ac28f9b46f51eea860536ab59">sendData()</a>.</p>
<div class="fragment"><pre class="fragment">                                                  {
  <span class="keywordflow">switch</span> (msg-&gt;getKind()) {
  <span class="keywordflow">case</span> SEND_DATA_TIMER:
    <a class="code" href="a00191.html#a874cfc7ac28f9b46f51eea860536ab59" title="send a data packet to the next hop">sendData</a>();
    <span class="comment">//delete msg;</span>
    <span class="keywordflow">break</span>;
  <span class="keywordflow">default</span>:
    EV&lt;&lt; <span class="stringliteral">&quot;Unkown selfmessage! -&gt; delete, kind: &quot;</span> &lt;&lt; msg-&gt;getKind() &lt;&lt; endl;
    <span class="keyword">delete</span> msg;
    <span class="keywordflow">break</span>;
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a999fc38567d79965df17646dcbf38e84"></a><!-- doxytag: member="SensorApplLayer::handleUpperMsg" ref="a999fc38567d79965df17646dcbf38e84" args="(cMessage *m)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void SensorApplLayer::handleUpperMsg </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [inline, protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Handle messages from upper layer. </p>
<p>This function is pure virtual here, because there is no reasonable guess what to do with it by default. </p>

<p>Implements <a class="el" href="a00025.html#a8c0fcfb2e806357a65d5bdb1c338627b">BaseLayer</a>.</p>
<div class="fragment"><pre class="fragment">        {
            <span class="keyword">delete</span> m;
        }
</pre></div>
</div>
</div>
<a class="anchor" id="ac9d94d2ed83444dbea11b6255f0cd1b0"></a><!-- doxytag: member="SensorApplLayer::hostsLatency" ref="ac9d94d2ed83444dbea11b6255f0cd1b0" args="(const LAddress::L3Type &amp;hostAddress)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cStdDev &amp; SensorApplLayer::hostsLatency </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a> &amp;&#160;</td>
          <td class="paramname"><em>hostAddress</em></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns the latency statistics variable for the passed host address. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">hostAddress</td><td>the address of the host to return the statistics for. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A reference to the hosts latency statistics. </dd></dl>

<p>Referenced by <a class="el" href="a00191.html#a1100fd46a8ced89ff27dd845de9c0d63">handleLowerMsg()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keyword">using</span> std::pair;

  <span class="keywordflow">if</span>(latencies.count(hostAddress) == 0) {
    std::ostringstream oss;
    oss &lt;&lt; hostAddress;
    cStdDev aLatency(oss.str().c_str());
    latencies.insert(pair&lt;LAddress::L3Type, cStdDev&gt;(hostAddress, aLatency));
  }

  <span class="keywordflow">return</span> latencies[hostAddress];
}
</pre></div>
</div>
</div>
<a class="anchor" id="aac9612746afd57f4393658789d3c64fe"></a><!-- doxytag: member="SensorApplLayer::initialize" ref="aac9612746afd57f4393658789d3c64fe" args="(int)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SensorApplLayer::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialization of the module and some variables. </p>
<p>First we have to initialize the module from which we derived ours, in this case <a class="el" href="a00031.html" title="Base class for all simple modules of a host that want to have access to the NotificationBoard module...">BasicModule</a>.</p>
<p>Then we will set a timer to indicate the first time we will send a message </p>

<p>Reimplemented from <a class="el" href="a00025.html#a70f5ea30a9980d57b8384faed29ec3eb">BaseLayer</a>.</p>

<p>References <a class="el" href="a00025.html#a665bf8ad06b2c4b5419669869e68ef00">BaseLayer::catPacketSignal</a>, <a class="el" href="a00191.html#a6d8bd1aaca78da940546c05fb597bf00">debug</a>, <a class="el" href="a00027.html#aabf0226159b22b46e70031fd3bb3b1b2">BaseModule::findHost()</a>, <a class="el" href="a00201.html#aa01f017b96087bc252445206777e0080">simsignalwrap_t::initialize()</a>, <a class="el" href="a00191.html#a08e69649b4aa1b598216c5aa2d12e940">initializeDistribution()</a>, and <a class="el" href="a00004.html#a3f4172beef51056ebc815246b6c9d651">AddressingInterface::myNetwAddr()</a>.</p>
<div class="fragment"><pre class="fragment">                                          {
    <a class="code" href="a00191.html#aac9612746afd57f4393658789d3c64fe" title="Initialization of the module and some variables.">BaseLayer::initialize</a>(stage);
  <span class="keywordflow">if</span> (stage == 0) {
    <a class="code" href="a00025.html#a665bf8ad06b2c4b5419669869e68ef00" title="SignalID for packets.">BaseLayer::catPacketSignal</a>.<a class="code" href="a00201.html#aa01f017b96087bc252445206777e0080">initialize</a>();

    debugEV&lt;&lt; <span class="stringliteral">&quot;in initialize() stage 0...&quot;</span>;
    <a class="code" href="a00191.html#a6d8bd1aaca78da940546c05fb597bf00" title="Debug switch for all other modules.">debug</a> = par(<span class="stringliteral">&quot;debug&quot;</span>);
    stats = par(<span class="stringliteral">&quot;stats&quot;</span>);
    trace = par(<span class="stringliteral">&quot;trace&quot;</span>);
    nbPackets = par(<span class="stringliteral">&quot;nbPackets&quot;</span>);
    trafficParam = par(<span class="stringliteral">&quot;trafficParam&quot;</span>);
    initializationTime = par(<span class="stringliteral">&quot;initializationTime&quot;</span>);
    broadcastPackets = par(<span class="stringliteral">&quot;broadcastPackets&quot;</span>);
    headerLength = par(<span class="stringliteral">&quot;headerLength&quot;</span>);
    <span class="comment">// application configuration</span>
    <span class="keyword">const</span> <span class="keywordtype">char</span> *traffic = par(<span class="stringliteral">&quot;trafficType&quot;</span>);
    destAddr = <a class="code" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4" title="Type definition for a L3 (Network) address.">LAddress::L3Type</a>(par(<span class="stringliteral">&quot;destAddr&quot;</span>).longValue());
    nbPacketsSent = 0;
    nbPacketsReceived = 0;
    firstPacketGeneration = -1;
    lastPacketReception = -2;

    <a class="code" href="a00191.html#a08e69649b4aa1b598216c5aa2d12e940" title="Recognize distribution name. Redefine this method to add your own distribution.">initializeDistribution</a>(traffic);

    delayTimer = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;appDelay&quot;</span>, SEND_DATA_TIMER);

    <span class="comment">// get pointer to the world module</span>
    world = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;BaseWorldUtility*&gt;::findGlobalModule</a>();

  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == 1) {
    debugEV &lt;&lt; <span class="stringliteral">&quot;in initialize() stage 1...&quot;</span>;
    <span class="comment">// Application address configuration: equals to host address</span>

    cModule *<span class="keyword">const</span> pHost = <a class="code" href="a00027.html#aabf0226159b22b46e70031fd3bb3b1b2" title="Function to get a pointer to the host module.">findHost</a>();
    <span class="keyword">const</span> cModule* netw  = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;BaseNetwLayer*&gt;::findSubModule</a>(pHost);
    <span class="keywordflow">if</span>(!netw) {
      netw = pHost-&gt;getSubmodule(<span class="stringliteral">&quot;netwl&quot;</span>);
      <span class="keywordflow">if</span>(!netw) {
        opp_error(<span class="stringliteral">&quot;Could not find network layer module. This means &quot;</span>
              <span class="stringliteral">&quot;either no network layer module is present or the &quot;</span>
              <span class="stringliteral">&quot;used network layer module does not subclass from &quot;</span>
              <span class="stringliteral">&quot;BaseNetworkLayer.&quot;</span>);
      }
    }
    <span class="keyword">const</span> <a class="code" href="a00004.html" title="Interface for modules which assign L2 and L3 addresses for modules.">AddressingInterface</a> *<span class="keyword">const</span> addrScheme = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;AddressingInterface*&gt;::findSubModule</a>(pHost);
    <span class="keywordflow">if</span>(addrScheme) {
      myAppAddr = addrScheme-&gt;<a class="code" href="a00004.html#a3f4172beef51056ebc815246b6c9d651" title="Returns the L3 address for the passed net.">myNetwAddr</a>(netw);
    } <span class="keywordflow">else</span> {
      myAppAddr = <a class="code" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4" title="Type definition for a L3 (Network) address.">LAddress::L3Type</a>( netw-&gt;getId() );
    }
    sentPackets = 0;

    <span class="comment">// first packet generation time is always chosen uniformly</span>
    <span class="comment">// to avoid systematic collisions</span>
    <span class="keywordflow">if</span>(nbPackets&gt; 0)
      scheduleAt(simTime() +uniform(initializationTime, initializationTime + trafficParam), delayTimer);

    <span class="keywordflow">if</span> (stats) {
      latenciesRaw.setName(<span class="stringliteral">&quot;rawLatencies&quot;</span>);
      latenciesRaw.setUnit(<span class="stringliteral">&quot;s&quot;</span>);
      latency.setName(<span class="stringliteral">&quot;latency&quot;</span>);
    }
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a874cfc7ac28f9b46f51eea860536ab59"></a><!-- doxytag: member="SensorApplLayer::sendData" ref="a874cfc7ac28f9b46f51eea860536ab59" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SensorApplLayer::sendData </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>send a data packet to the next hop </p>
<p>This function creates a new data message and sends it down to the network layer. </p>

<p>References <a class="el" href="a00025.html#a665bf8ad06b2c4b5419669869e68ef00">BaseLayer::catPacketSignal</a>, <a class="el" href="a00117.html#a11d63e8d897e072ed94da77028d38f60">LAddress::L3BROADCAST</a>, <a class="el" href="a00191.html#a246b38e417b96f476d61a5f6899a11b7">scheduleNextPacket()</a>, <a class="el" href="a00025.html#a1873d6e3fc6d92cf8482b39f1c5ac6c8">BaseLayer::sendDown()</a>, and <a class="el" href="a00155.html#a8e95c523ae2e3136ab34313da7384dea">NetwControlInfo::setControlInfo()</a>.</p>

<p>Referenced by <a class="el" href="a00191.html#af822f0d57cf5642efe603f6fd83612c0">handleSelfMsg()</a>.</p>
<div class="fragment"><pre class="fragment">                               {
  ApplPkt *pkt = <span class="keyword">new</span> ApplPkt(<span class="stringliteral">&quot;Data&quot;</span>, DATA_MESSAGE);

  <span class="keywordflow">if</span>(broadcastPackets) {
    pkt-&gt;setDestAddr(<a class="code" href="a00117.html#a11d63e8d897e072ed94da77028d38f60" title="Broadcast address for L3 addresses.">LAddress::L3BROADCAST</a>);
  } <span class="keywordflow">else</span> {
    pkt-&gt;setDestAddr(destAddr);
  }
  pkt-&gt;setSrcAddr(myAppAddr);
  pkt-&gt;setByteLength(headerLength);
  <span class="comment">// set the control info to tell the network layer the layer 3 address</span>
  <a class="code" href="a00155.html#a8e95c523ae2e3136ab34313da7384dea" title="Attaches a &quot;control info&quot; structure (object) to the message pMsg.">NetwControlInfo::setControlInfo</a>(pkt, pkt-&gt;getDestAddr());
  debugEV&lt;&lt; <span class="stringliteral">&quot;Sending data packet!\n&quot;</span>;
  <a class="code" href="a00025.html#a1873d6e3fc6d92cf8482b39f1c5ac6c8" title="Sends a message to the lower layer.">sendDown</a>(pkt);
  nbPacketsSent++;
  packet.setPacketSent(<span class="keyword">true</span>);
  packet.setNbPacketsSent(1);
  packet.setNbPacketsReceived(0);
  packet.setHost(myAppAddr);
  emit(<a class="code" href="a00025.html#a665bf8ad06b2c4b5419669869e68ef00" title="SignalID for packets.">BaseLayer::catPacketSignal</a>, &amp;packet);
  sentPackets++;
  <a class="code" href="a00191.html#a246b38e417b96f476d61a5f6899a11b7" title="calculate time to wait before sending next packet, if required. You can redefine this method in a sub...">scheduleNextPacket</a>();
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/application/<a class="el" href="a00414_source.html">SensorApplLayer.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/application/SensorApplLayer.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00191.html">SensorApplLayer</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
